package kit.edu.lego.gruppe3.levels.treeArea;

import kit.edu.lego.gruppe3.ComponentsRepository;
import kit.edu.lego.gruppe3.levels.LevelSelector;
import kit.edu.lego.gruppe3.levels.treeArea.entrance.EntranceSolver;
import lejos.nxt.TouchSensor;
import lejos.robotics.subsumption.Behavior;

public class ObstacleFinder implements Behavior{
	

	private TouchSensor leftTouch = ComponentsRepository.getInstance().getLeftTouchSensor();
	private TouchSensor rightTouch = ComponentsRepository.getInstance().getRightTouchSensor();

	
	@Override
	public void action() {
		TreeAreaSolver.objectFound = true;
		EntranceSolver entranceSolver = new EntranceSolver();
		entranceSolver.start();
	}

	@Override
	public void suppress() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean takeControl() {
		return LevelSelector.getInstance().isTreeArea() &&
			(rightTouch.isPressed() || leftTouch.isPressed()) &&
			!TreeAreaSolver.objectFound &&
			RotateMovement.triggerTouch;
	}

}
